home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / ezmouse2.zip / EZMOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-11  |  6KB  |  226 lines

  1. {
  2.                 PROGRAM: Easy Mouse Lib Ver 2.0, SHAREWARE
  3.                 AUTHOR: Jeff Weinstein
  4.                 DATE STARTED: 4/7/96
  5.                 DATE FINISHED: 4/13/96
  6.                 UPDATE:5/11/96 -Ver 2.0
  7.                 Copyright (c) 1996, by Jeff Weinstein.  All rights reserved.
  8. }
  9.  
  10.  
  11. unit ezmouse;
  12.  
  13. Interface
  14.          uses crt, dos;
  15.  
  16. {******************************TYPES*****************************}
  17.  
  18. type
  19.     EMouseType = (UNDEF,BUS,SERIAL,INPORT,PS2,HP);
  20.  
  21.  
  22.  
  23. {***************************CONSTANTS****************************}
  24.  
  25. const
  26.      LEFT_BUTTON = 0;
  27.      RIGHT_BUTTON = 1;
  28.  
  29. {**************************VARIABLES*****************************}
  30.  
  31. var
  32.          iv,bt : word;
  33.          MouseInstalled, NumberOfButtons : Integer; {is installed, #buttons}
  34.          MouseX,MouseY:Integer; {mouse coords}
  35.          LeftPressed, RightPressed:Integer; {are they pressed}
  36.          dummy:integer;
  37.          ButtonX,ButtonY:integer;
  38.          MouseMajor,MouseMinor:byte;
  39.          MouseType : EMouseType;
  40.          MouseIRQ  : byte;
  41.  
  42.  
  43.  
  44. {*****************************PROCEDURES**************************}
  45.  
  46.          procedure InstallMouse; {installs mouse driver}
  47.          procedure ShowMouse; {displays mouse on screen}
  48.          procedure HideMouse; {hides mouse}
  49.          procedure MouseXY; {retrieves mouse current coordinates}
  50.          procedure ButtonPress; {tells which button(s) are being held down}
  51.          procedure SetMouseXY(x,y:integer); {moves mouse to x,y}
  52.          procedure ButtonClick(button:integer); {determines where last BUTTON click was}
  53.          procedure ConfineMouse(MinX,MinY,MaxX,MaxY:integer); {confines mouse to window}
  54.          procedure NormalConfine; {resets mouse confines to normal}
  55.          procedure MouseInfo; {gets ver, IRQ, type}
  56.          Procedure ResetMouse;
  57.          Procedure ChangeCursor(Offs,Segm:word;hhs,vhs:integer); {creates new cursor}
  58.  
  59. Implementation
  60.  
  61.          procedure InstallMouse;
  62.              begin
  63.                 {set shareware delay}
  64.                 textcolor(4);
  65.                 writeln('This is the SHAREWARE version of EZ-Mouse.');
  66.                 writeln('Why not register?  It''s only $5 including S/H.');
  67.                 writeln('See the file REGISTER.TXT for details.');
  68.                 writeln('There will be a 12 second delay before the mouse initializes');
  69.                 delay(12000);
  70.                 textcolor(7);
  71.  
  72.                 {procedure installs mouse and returns succes, #buttons}
  73.                 asm
  74.                    mov ax, 0h
  75.                    int 33h
  76.                    mov [iv], ax
  77.                    mov [bt], bx
  78.                 end;
  79.                 if iv=65535 then MouseInstalled:=-1; {mouse is installed}
  80.                 if iv<>65535 then MouseInstalled:=0; {not installed}
  81.                 NumberOfButtons:=bt;
  82.            end;
  83.  
  84.  
  85.          Procedure ShowMouse;
  86.          begin
  87.               asm
  88.                  mov ax,01h
  89.                  int 33h
  90.               end;
  91.          end;
  92.  
  93.  
  94.          Procedure HideMouse;
  95.          begin
  96.               asm
  97.                  mov ax,02h
  98.                  int 33h
  99.               end;
  100.          end;
  101.  
  102.  
  103.          Procedure MouseXY;
  104.          begin
  105.               asm
  106.                  mov ax,03h
  107.                  int 33h
  108.                  mov [dummy],bx
  109.                  mov [MouseX],cx
  110.                  mov [MouseY],dx
  111.               end;
  112.  
  113.          end;
  114.  
  115.          Procedure ButtonPress;
  116.          begin
  117.               asm
  118.                  mov ax,03h
  119.                  int 33h
  120.                  mov [dummy],bx
  121.               end;
  122.               if dummy=1 then
  123.                  begin
  124.                       LeftPressed:=-1;
  125.                       RightPressed:=0;
  126.                  end;
  127.               if dummy=2 then begin
  128.                  LeftPressed:=0;
  129.                  RightPressed:=-1;
  130.                  end;
  131.               if dummy=3 then begin
  132.                  LeftPressed:=-1;
  133.                  RightPressed:=-1;
  134.                  end;
  135.               if (((dummy<>1) and (dummy<>2)) and (dummy<>3)) then begin
  136.                  LeftPressed:=0;
  137.                  RightPressed:=0;
  138.                  end;
  139.          end;
  140.  
  141.  
  142.          Procedure SetMouseXY(x,y:integer);
  143.          begin
  144.               asm
  145.                  mov ax,04h
  146.                  mov cx,[x]
  147.                  mov dx,[y]
  148.                  int 33h
  149.               end;
  150.          end;
  151.  
  152.  
  153.         Procedure ButtonClick(button:integer);
  154.         begin
  155.              asm
  156.                 mov ax,05h
  157.                 mov bx,[button]
  158.                 int 33h
  159.                 mov [ButtonX],cx
  160.                 mov [ButtonY],dx
  161.              end;
  162.         end;
  163.  
  164.  
  165.         procedure ConfineMouse(MinX,MinY,MaxX,MaxY:integer);
  166.         begin
  167.              asm
  168.                 mov ax,07h {first do the x's}
  169.                 mov cx,[MinX]
  170.                 mov dx,[MaxX]
  171.                 int 33h
  172.                 mov ax,08h
  173.                 mov cx,[MinY]
  174.                 mov dx,[MaxY]
  175.                 int 33h
  176.              end;
  177.         end;
  178.  
  179.         procedure NormalConfine;
  180.         begin
  181.              asm
  182.                 mov ax,07h
  183.                 mov cx,0
  184.                 mov dx,639
  185.                 int 33h
  186.                 mov ax,08h
  187.                 mov cx,0
  188.                 mov dx,199
  189.                 int 33h
  190.              end;
  191.         end;
  192.  
  193.  
  194.         procedure MouseInfo;
  195.         begin
  196.              asm
  197.                 mov ax,24h
  198.                 int 33h
  199.                 mov [MouseMajor],bh
  200.                 mov [MouseMinor],bl
  201.                 mov [MouseType],ch
  202.                 mov [MouseIRQ],cl
  203.              end;
  204.         end;
  205.  
  206.  
  207.         Procedure ResetMouse;assembler;
  208.         asm
  209.            mov ax,21h
  210.            int 33h
  211.         end;
  212.  
  213.         Procedure ChangeCursor(Offs,Segm:word;hhs,vhs:integer);assembler;
  214.         asm
  215.                mov ax,09h
  216.                mov bx,[hhs]
  217.                mov cx,[vhs]
  218.                mov es,[Segm]
  219.                mov dx,[Offs]
  220.                int 33h
  221.         end;
  222.  
  223.  
  224.  
  225.  
  226. end.